
7F004760:	primary expansion routine
JAL	7F09A464	//returns V0=#players
ADDIU	S0,R0,0001	//ensures solo ammo boxes appear
SLTI	AT,V0,0002
BNEZ	AT,7F0047A8	//branch if solo
NOP
//7F004774:	MP ammo attributement
JAL	7F0C6614	//returns V0=pointer to weapon set
NOP
LUI	T6,8007
LW	T6,9540 (T6)	//T6=80069540	last MP weapon# or -1
SLL	T8,T6,0x2
SUBU	T8,T8,T6
SLL	T8,T8,0x3	//T8=weapon# * 0x18 (offset to data)
ADDU	V1,V0,T8
LW	A0,000C (V1)	//A0=ammo type
LW	S0,0010 (V1)	//S0=amount of ammo
SLL	T0,A0,0x2	//offset within ammo list
ADDU	T1,S2,T0
SH	S0,007E (T1)	//save ammo total to proper HW slot
//7F0047A8:	generic Solo/MP ammo box stuff
BLEZ	S0,7F004AFC	//if no ammo for ammo box, don't render
NOP
BEQ	S8,R0,7F004AFC	//generic objects appear flag test
NOP
LW	T9,000C (S2)	//second 32bit flagfield
OR	S1,R0,R0	//S1=0 (ammo counter)
OR	S0,S2,R0	//S0=object data offset
AND	T2,T9,S4
BNEZ	T2,7F004AFC	//test if killflags present
NOP
//7F0047D0:	test if any ammo actually assigned
LHU	T3,0082 (S0)	//T3=ammo total for slot
BLEZL	T3,7F0047F4	//if not valid, NEXT!
ADDIU	S1,S1,0004
LHU	A0,0080 (S0)	//A0=first halfword apparently is a model #
BEQL	S6,A0,7F0047F4	//if A0=FFFF, NEXT!	(S6=FFFF, somehow)
ADDIU	S1,S1,0004
JAL	7F056C38	//load model A0!
NOP
ADDIU	S1,S1,0004
//7F0047F4:
BNE	S1,S7,7F0047D0	//test until S1=34 (S7=34, apparently)
ADDIU	S0,S0,0004
OR	A0,S5,R0
OR	A1,S2,R0
JAL	7F001D9C	//expand object
OR	A2,S3,R0
BEQ	R0,R0,7F004AFC
NOP


reads ammo to determine collectability
//7F050980:	ammo box collectability
24010014	ADDIU	AT,R0,0014
1441002C	BNE	V0,AT,7F050A38	;if object isn't an ammo box, try BA instead
8FA90088	LW	T1,0088 (SP)
//7F05098C:	test if the thing is even collectable...
8D2A0004	LW	T2,0004 (T1)	;T2=p->obj.data	(T1=obj.pos data in 8006)
240B0001	ADDIU	T3,R0,0001
AFAB006C	SW	T3,006C (SP)	;SP+6C= 1
00A02025	OR	A0,A1,R0	;A0=A1: p->obj.data
0FC0FFF0	JAL	7F03FFC0	;ret V0!=0 if object was destroyed
AFAA0070	SW	T2,0070 (SP)	;SP+70= p->obj.data
//7F0509A4:
10400003	BEQ	V0,R0,7F0509B4	;branch if not destroyed
8FA30070	LW	V1,0070 (SP)	;V1=p->obj.data
100000DC	BEQ	R0,R0,7F050D20	;quit if object destroyed
00001025	OR	V0,R0,R0	;V0=0
//7F0509B4:	854E4	initialize loop if object valid
00001025	OR	V0,R0,R0	;V0=0	current ammo type -1
//7F0509B8:	854E8	loop for ?
24450001	ADDIU	A1,V0,0001	;A1=V0+1	next type
24010001	ADDIU	AT,R0,0001	;AT=1
14410002	BNE	V0,AT,7F0509CC	;redirect ammo type 2 to 1
00A02025	OR	A0,A1,R0	;A0=type+1	counter->type conversion
24040001	ADDIU	A0,R0,0001	;A0=1
//7F0509CC:	854FC	
946C0082	LHU	T4,0082 (V1)	;T4=ammo for type
59800011	BLEZL	T4,7F050A18	;if no ammo (or stupid ammo), loopus
2401000D	ADDIU	AT,R0,000D	;AT=D: total number of ammo types in a box
AFA30030	SW	V1,0030 (SP)	;save p->obj+offset to current ammo
AFA40064	SW	A0,0064 (SP)	;SP+64= type of ammo
0FC1A490	JAL	7F069240	;ret V0=player's total ammo of type A0
AFA50034	SW	A1,0034 (SP)	;SP+34= curtype
8FA40064	LW	A0,0064 (SP)	;A0=type of ammo
0FC1A4B5	JAL	7F0692D4	;ret V0=max ammo for type A0
AFA20038	SW	V0,0038 (SP)	;SP+38= stock
8FA60038	LW	A2,0038 (SP)	;A2=stock
8FA30030	LW	V1,0030 (SP)	;V1= p->obj.cur.type
8FA50034	LW	A1,0034 (SP)	;A1= curtype
00C2082A	SLT	AT,A2,V0	;AT=TRUE if stock<max
50200004	BEQL	AT,R0,7F050A18	;branch if you already had enough stuff
2401000D	ADDIU	AT,R0,000D	;AT=D: total number of ammo types in a box
10000005	BEQ	R0,R0,7F050A24	;if you can use the box, no more need to loop
AFA0006C	SW	R0,006C (SP)	;SP+6C= 0
//7F050A14:	loop for all types
2401000D	ADDIU	AT,R0,000D	;AT=D: total number of ammo types in a box
00A01025	OR	V0,A1,R0	;V0=A1: V0=next type
14A1FFE6	BNE	A1,AT,7F0509B8
24630004	ADDIU	V1,V1,0004	;V1+=4: p->next ammo type in obj.
//7F050A24:
8FAD006C	LW	T5,006C (SP)	;T5=0 if collectable, 1 if not
11A00031	BEQ	T5,R0,7F050AF0	;branch if collectable
00000000	NOP
100000BB	BEQ	R0,R0,7F050D20	;quit otherwise
00001025	OR	V0,R0,R0	;V0=0


